$(document).ready(function(){
	
	var $corporation = $('#corporation');
	var $company = $('#company');
    var $department= $('#department');
    var $hotelId = $('#hotel_id');

    if(!EOVA_FORM)
        return;

    var cmbCorporation = $corporation.eovacombo();
    var cmbCompany = $company.eovacombo();
    var cmbDepartment = $department.eovacombo();

    // 初始禁用
    cmbCompany.readonly(true);
    cmbDepartment.readonly(true);
    if($corporation !=""){
        cmbCompany.readonly(false);
        $company.eovacombo({exp : 'selectOrgByLv2AndPid,' + 20000000}).reload();
    }

    // 省级联市
    $corporation.eovacombo({onChange: function (oldValue, newValue) {
        cmbCompany.setValue("");
        cmbDepartment.setValue("");
        if (newValue == "") {
        	cmbCompany.readonly(true)
            return;
        }
        cmbCompany.readonly(false);
        $company.eovacombo({exp : 'selectOrgByLv2AndPid,' + newValue}).reload();
    }});

 	// 省级联市
    $company.eovacombo({onChange: function (oldValue, newValue) {
        cmbDepartment.setValue("");
        if (newValue == "") {
            cmbDepartment.readonly(true);
            return;
        }
        cmbDepartment.readonly(false);
        $department.eovacombo({exp : 'selectOrgByLv3AndPid,' + newValue}).reload();
    }});

    $department.eovacombo({onChange: function (oldValue, newValue){
            $hotelId.eovafind().setValue("");
            if("" == newValue){
                $hotelId.eovafind().readonly(true);
                return;
            }
            $hotelId.eovafind().readonly(false);
            $hotelId.eovafind({exp:'selectHotelByDepartment,'+newValue});

        }});
    
});